using Microsoft.Extensions.Configuration;

namespace KrigingTest;

public class ConfigHelper
{
    /// <summary>
    /// 获取配置
    /// </summary>
    /// <returns></returns>
    public static IConfigurationRoot GetConfig()
    {
        return new ConfigurationBuilder()
            .SetBasePath(AppContext.BaseDirectory)
            .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
            .Build();
    }

    /// <summary>
    /// 获取配置值
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    public static string? GetConfigValue(string key)
    {
        return GetConfig()[key];
    }

    /// <summary>
    /// 获取配置值
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    public static object? GetConfigObjectValue(string key)
    {
        return GetConfig()[key];
    }
}